﻿x.lang.Ba.prototype.ei = ia(0, function () {
    delete window[x.ca]._instances[this.ca];
    for (var a in this) x.lang.it(this[a]) || delete this[a]
});
x.D.getComputedStyle = function (a, b) {
    var a = x.D.Qj(a),
        c = x.D.CD(a);
    return c.defaultView && c.defaultView.getComputedStyle && (c = c.defaultView.getComputedStyle(a, p)) ? c[b] || c.getPropertyValue(b) : ""
};
x.D.remove = function (a) {
    var a = x.D.Qj(a),
        b = a.parentNode;
    b && b.removeChild(a)
};
x.lang.isArray = function (a) {
    return "[object Array]" == Object.prototype.toString.call(a)
};
x.event = x.event || {};
x.event.stopPropagation = function (a) {
    a.stopPropagation ? a.stopPropagation() : a.cancelBubble = o
};
x.event.preventDefault = function (a) {
    a.preventDefault ? a.preventDefault() : a.returnValue = q
};
x.event.stop = function (a) {
    var b = x.event;
    b.stopPropagation(a);
    b.preventDefault(a)
};
x.jc.indexOf = function (a, b, c) {
    var d = a.length,
        c = c | 0;
    for (0 > c && (c = Math.max(0, d + c)) ; c < d; c++)
        if (c in a && a[c] === b) return c;
    return -1
};
x.jc.contains = function (a, b) {
    return 0 <= x.jc.indexOf(a, b)
};
x.Qb = x.Qb || {
    version: "1.3.9"
};
x.Qb.wX = function (a) {
    for (var a = a.split("-"), b = x.Qb, c = a.length, d = 0; d < c; d++) b = b[a[d].charAt(0).toUpperCase() + a[d].slice(1)];
    return b
};
x.Qb.create = function (a, b) {
    x.lang.ug(a) && (a = x.Qb.wX(a));
    return new a(b)
};
x.event.LA = x.event.LA || [];
x.event.K = function (a, b, c) {
    function d(b) {
        c.call(a, b)
    }
    var b = b.replace(/^on/i, ""),
        a = x.D.Qj(a),
        e = x.event.LA,
        f = x.event.t0,
        g = b,
        b = b.toLowerCase();
    f && f[b] && (f = f[b](a, b, d), g = f.type, d = f.P2);
    a && a.addEventListener ? a.addEventListener(g, d, q) : a && a.attachEvent && a.attachEvent("on" + g, d);
    e[e.length] = [a, b, c, d, g];
    return a
};
x.K = x.event.K;
x.event.bd = function (a, b, c) {
    for (var a = x.D.Qj(a), b = b.replace(/^on/i, "").toLowerCase(), d = x.event.LA, e = d.length, f = !c, g, i; e--;)
        if (g = d[e], g[1] === b && g[0] === a && (f || g[2] === c)) i = g[4], g = g[3], a.removeEventListener ? a.removeEventListener(i, g, q) : a.detachEvent && a.detachEvent("on" + i, g), d.splice(e, 1);
    return a
};
x.bd = x.event.bd;
x.Qb.WF = {
    id: "",
    Xb: function (a) {
        var b;
        b = "tangram-" + this.ku + "--" + (this.id ? this.id : this.ca);
        return a ? b + "-" + a : b
    },
    Ms: function (a) {
        var b = this.VJ,
            c = this.YZ;
        a && (b += "-" + a, c += "-" + a);
        this.YZ && (b += " " + c);
        return b
    },
    ki: function () {
        return x.$(this.qM)
    },
    EW: function () {
        return x.$(this.Xb())
    },
    ku: "",
    Ro: function () {
        return "window['$BAIDU$']._instances['" + this.ca + "']"
    },
    P1: function (a) {
        for (var b = 0, c = Array.prototype.slice.call(arguments, 1), d = c.length; b < d; b++) "string" == typeof c[b] && (c[b] = "'" + c[b] + "'");
        return this.Ro() + "." + a + "(" + c.join(",") + ");"
    },
    K: function (a, b, c) {
        x.K(a, b, c);
        this.addEventListener("ondispose", function () {
            x.bd(a, b, c)
        })
    },
    dZ: function (a) {
        if (!this.ki()) return a = x.$(a), a || (a = document.createElement("div"), document.body.appendChild(a), a.style.position = "absolute", a.className = this.Ms("main")), a.id || (a.id = this.Xb("main")), this.qM = a.id, a.setAttribute("data-guid", this.ca), a
    },
    ei: function () {
        this.dispatchEvent("dispose");
        x.lang.Ba.prototype.ei.call(this)
    }
};
x.Qb.DV = function (a) {
    function b() { }

    function c(b, d) {
        var m = this,
            b = b || {};
        e.call(m, !f ? b : b.ca || "", o);
        x.object.extend(m, c.options);
        x.object.extend(m, b);
        m.VJ = m.VJ || "tangram-" + m.ku.toLowerCase();
        for (g in x.Qb.Tl) "undefined" != typeof m[g] && m[g] && (x.object.extend(m, x.Qb.Tl[g]), x.lang.it(m[g]) ? m.addEventListener("onload", function () {
            x.Qb.Tl[g].call(m[g].apply(m))
        }) : x.Qb.Tl[g].call(m));
        a.apply(m, arguments);
        g = 0;
        for (i = c.kz.length; g < i; g++) c.kz[g](m);
        b.parent && m.NZ && m.NZ(b.parent);
        !d && b.X0 && m.ta(b.element)
    }
    var d;
    d = d || {};
    var e = d.g_ || x.lang.Ba,
        f = e == x.lang.Ba ? 1 : 0,
        g, i;
    b.prototype = e.prototype;
    d = c.prototype = new b;
    for (g in x.Qb.WF) d[g] = x.Qb.WF[g];
    c.extend = function (a) {
        for (g in a) c.prototype[g] = a[g];
        return c
    };
    c.kz = [];
    c.Te = function (a) {
        "function" == typeof a && c.kz.push(a)
    };
    c.options = {};
    return c
};
x.D.xD = function (a, b) {
    a = x.D.$(a);
    if (a === p) return a;
    if ("style" == b) return a.style.cssText;
    b = x.D.sG[b] || b;
    return a.getAttribute(b)
};
x.xD = x.D.xD;
x.Qb.get = function (a) {
    var b;
    if (x.lang.ug(a)) return x.lang.Mc(a);
    do {
        if (!a || 9 == a.nodeType) return p;
        if (b = x.D.xD(a, "data-guid")) return x.lang.Mc(b)
    } while ((a = a.parentNode) != document.body)
};
x.Qb.Gi = x.Qb.DV(function () {
    var a = this;
    a.addEventListener("onload", function () {
        eventName = G() ? "touchstart" : "mousedown";
        a.K(document, eventName, a.UV);
        a.K(window, "blur", a.Q_)
    });
    a.UV = a.FR();
    a.Q_ = a.fS();
    a.pk = [];
    a.Xc = -1
}).extend({
    ku: "suggestion",
    b3: new Function,
    f3: new Function,
    c3: new Function,
    e3: new Function,
    h3: new Function,
    d3: new Function,
    getData: function () {
        return []
    },
    s3: "",
    V0: "",
    em: {},
    v_: "<div id='#{0}' class='#{1}' style='position:relative; top:0px; left:0px'></div>",
    a4: "<div id='#{0}' class='#{1}'>#{2}</div>",
    u_: '<div style="height:22px;line-height:22px;overflow:hidden;zoom:1;border-top:#E7E7E7 solid 1px;background:#F7F7F7;"><span style="float:right;color:#4B4B4B;border-left:1px solid #E7E7E7;padding:0 10px;font-size:14px;" onmousedown="#{0}">关闭</span></div>',
    t_: '<table cellspacing="0" cellpadding="2"><tbody>#{0}</tbody></table>',
    w_: '<tr><td id="#{0}" onmouseover="#{2}" onmouseout="#{3}" onmousedown="#{4}" onclick="#{5}" class="#{6}"><i class="route-icon">#{1}</i></td></tr>',
    mX: function () {
        return x.Oo(this.v_, this.Xb(), this.Ms(), this.ca)
    },
    ta: function (a, b) {
        var c, a = x.$(a);
        this.UB = b;
        !this.ki() && a && (this.i_ = a.id ? a.id : a.id = this.Xb("input"), c = this.dZ(), c.style.display = "none", c.innerHTML = this.mX(), this.dispatchEvent("onload"))
    },
    FA: function () {
        var a = this.ki();
        return a && "none" != a.style.display
    },
    zj: function (a) {
        var b = this.em,
            a = {
                data: {
                    item: (b && "number" == typeof a && "undefined" != typeof b[a] ? b[a].value : a) == a ? {
                        value: a,
                        content: a
                    } : b[a],
                    index: a
                }
            };
        this.dispatchEvent("onbeforepick", a) && this.dispatchEvent("onpick", a)
    },
    show: function (a, b, c) {
        var a = 0,
            d = b.length;
        this.pk = [];
        this.Xc = -1;
        if (0 == d && !c) this.U();
        else {
            for (this.em = []; a < d; a++) "undefined" != typeof b[a].value ? this.em.push(b[a]) : this.em.push({
                value: b[a],
                content: b[a]
            }), ("undefined" == typeof b[a].disable || b[a].disable == q) && this.pk.push(a);
            this.EW().innerHTML = this.AR();
            this.ki().style.display = "block";
            this.dispatchEvent("onshow")
        }
    },
    U: function () {
        if (this.FA()) {
            if (0 <= this.Xc && this.GX)
                for (var a = this.em, b = -1, c = 0, d = a.length; c < d; c++)
                    if ("undefined" == typeof a[c].disable || a[c].disable == q) b++, b == this.Xc && this.zj(c);
            this.ki().style.display = "none";
            this.dispatchEvent("onhide")
        }
    },
    at: function (a) {
        var b = this.pk,
            c = p;
        this.$q(a) && (0 <= this.Xc && this.PG(), c = this.uH(a), x.Ta(c, this.Ms("current")), this.Xc = x.jc.indexOf(b, a), this.dispatchEvent("onhighlight", {
            index: a,
            data: this.lm(a)
        }))
    },
    fC: function () {
        var a = this.pk[this.Xc];
        this.PG() && this.dispatchEvent("onclearhighlight", {
            index: a,
            data: this.lm(a)
        })
    },
    PG: function () {
        var a = this.Xc,
            b = this.pk,
            c = p;
        return 0 <= a ? (c = this.uH(b[a]), x.Rb(c, this.Ms("current")), this.Xc = -1, o) : q
    },
    confirm: function (a, b) {
        if ("keyboard" == b || this.$q(a)) this.zj(a), this.dispatchEvent("onconfirm", {
            data: this.lm(a) || a,
            source: b
        }), this.Xc = -1, this.U()
    },
    lm: function (a) {
        return {
            item: this.em[a],
            index: a
        }
    },
    QD: function () {
        return this.rm().value
    },
    rm: function () {
        return x.$(this.i_)
    },
    uH: function (a) {
        return x.$(this.Xb("item" + a))
    },
    AR: function () {
        for (var a = "", b = [], c = this.em, d = c.length, e = 0; e < d; e++) b.push(x.Oo(this.w_, this.Xb("item" + e), c[e].content, this.Ro() + "._itemOver(event, " + e + ")", this.Ro() + "._itemOut(event, " + e + ")", this.Ro() + "._itemDown(event, " + e + ")", this.Ro() + "._itemClick(event, " + e + ")", "undefined" == typeof c[e].disable || c[e].disable == q ? "" : this.Ms("disable")));
        a += x.Oo(this.t_, b.join(""));
        G() && (a += x.Oo(this.u_, this.Ro() + "._close(event)"));
        return a
    },
    _close: function () {
        this.U()
    },
    _itemOver: function (a, b) {
        x.event.stop(a || window.event);
        this.$q(b) && this.at(b);
        this.dispatchEvent("onmouseoveritem", {
            index: b,
            data: this.lm(b)
        })
    },
    _itemOut: function (a, b) {
        x.event.stop(a || window.event);
        this.GX || this.$q(b) && this.fC();
        this.dispatchEvent("onmouseoutitem", {
            index: b,
            data: this.lm(b)
        })
    },
    _itemDown: function (a, b) {
        x.event.stop(a || window.event);
        this.dispatchEvent("onmousedownitem", {
            index: b,
            data: this.lm(b)
        })
    },
    _itemClick: function (a, b) {
        x.event.stop(a || window.event);
        this.dispatchEvent("onitemclick", {
            index: b,
            data: this.lm(b)
        });
        this.$q(b) && this.confirm(b, "mouse")
    },
    $q: function (a) {
        return x.jc.contains(this.pk, a)
    },
    FR: function () {
        var a = this;
        return function (b) {
            var b = b || window.event,
                b = b.target || b.srcElement,
                c = x.Qb.get(b);
            b == a.rm() || c && c.ku == a.ku || a.U()
        }
    },
    fS: function () {
        var a = this;
        return function () {
            a.U()
        }
    },
    ei: function () {
        this.dispatchEvent("dispose");
        x.D.remove(this.qM);
        x.lang.Ba.prototype.ei.call(this)
    }
});
x.Qb.Tl = x.Qb.Tl || {};
x.D.children = function (a) {
    a = x.D.$(a);
    if (a === p) return a;
    for (var b = [], a = a.firstChild; a; a = a.nextSibling) 1 == a.nodeType && b.push(a);
    return b
};
x.D.insertBefore = function (a, b) {
    var c;
    c = x.D.Qj;
    a = c(a);
    b = c(b);
    (c = b.parentNode) && c.insertBefore(a, b);
    return a
};
x.D.Kd = function (a, b, c) {
    var d = x.D,
        e, a = d.$(a),
        b = x.Ok.cO(b);
    if (e = d.Gl) c = e.filter(b, c, "set");
    (e = d.BB[b]) && e.set ? e.set(a, c) : a.style[e || b] = c;
    return a
};
x.Kd = x.D.Kd;
x.D.xi = function (a, b) {
    a = x.D.$(a);
    if (a === p) return a;
    for (var c in b) x.D.Kd(a, c, b[c]);
    return a
};
x.xi = x.D.xi;
x.D.Gl[x.D.Gl.length] = {
    set: function (a, b) {
        b.constructor == Number && !/zIndex|fontWeight|opacity|zoom|lineHeight/i.test(a) && (b += "px");
        return b
    }
};
x.D.Jt = function (a, b) {
    function c(a, b) {
        return parseFloat(x.tj(a, b)) || 0
    }
    var d = {};
    b.width && (d.width = parseFloat(b.width));
    b.height && (d.height = parseFloat(b.height));
    if (x.ea.oE && (b.width && (d.width = parseFloat(b.width) - c(a, "paddingLeft") - c(a, "paddingRight") - c(a, "borderLeftWidth") - c(a, "borderRightWidth"), 0 > d.width && (d.width = 0)), b.height)) d.height = parseFloat(b.height) - c(a, "paddingTop") - c(a, "paddingBottom") - c(a, "borderTopWidth") - c(a, "borderBottomWidth"), 0 > d.height && (d.height = 0);
    return x.D.xi(a, d)
};
(function () {
    var a = x.Qb.Tl.gK = s();
    a.Uy = q;
    a.Yp;
    a.$F;
    a.aG;
    a.TO = function () {
        if (this.Yp) this.UO(), x.Kd(this.Yp, "display", "block");
        else {
            var a = this.tV || {}, c = this.$F = a.Ua || this.ki(),
                d = a.opacity || "0",
                a = a.color || "",
                e = this.Yp = document.createElement("iframe"),
                f = this.aG = document.createElement("div");
            0 < x.D.children(c).length ? x.D.insertBefore(f, c.firstChild) : c.appendChild(f);
            x.xi(f, {
                position: "absolute",
                top: "0px",
                left: "0px"
            });
            x.D.Jt(f, {
                width: c.offsetWidth,
                height: c.offsetHeight
            });
            x.D.Jt(e, {
                width: f.offsetWidth
            });
            x.D.xi(e, {
                zIndex: -1,
                display: "block",
                border: 0,
                backgroundColor: a,
                filter: "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=" + d + ")"
            });
            f.appendChild(e);
            e.src = "javascript:void(0)";
            e.frameBorder = "0";
            e.scrolling = "no";
            e.height = "97%";
            this.Uy = o
        }
    };
    a.SO = function () {
        var a = this.Yp;
        this.Uy && (x.Kd(a, "display", "none"), this.Uy = q)
    };
    a.UO = function () {
        var a;
        a = a || {};
        var c = this.$F,
            d = this.aG,
            e = this.Yp;
        x.D.Jt(d, {
            width: c.offsetWidth,
            height: c.offsetHeight
        });
        x.D.Jt(e, x.extend({
            width: x.tj(d, "width")
        }, a))
    }
})();
x.extend(x.Qb.Gi.prototype, {
    gK: o,
    tV: {}
});
x.Qb.Gi.Te(function (a) {
    a.gK && (a.addEventListener("onshow", function () {
        a.TO()
    }), a.addEventListener("onhide", function () {
        a.SO()
    }))
});
x.Qb.Gi.extend({
    setData: function (a, b, c) {
        this.xC[a] = b;
        c || this.show(a, this.xC[a])
    }
});
x.Qb.Gi.Te(function (a) {
    a.xC = {};
    a.addEventListener("onneeddata", function (b, c) {
        var d = a.xC;
        "undefined" == typeof d[c] ? a.getData(c) : a.show(c, d[c])
    })
});
x.D.LZ = x.D.G3 = function (a, b) {
    return x.D.Jt(a, {
        width: b
    })
};
x.D.AX = function (a) {
    a = x.D.$(a);
    if (a === p) return a;
    a = x.D.CD(a);
    return a.parentWindow || a.defaultView || p
};
x.D.ra = function (a, b) {
    return x.D.xi(a, {
        left: b.left - (parseFloat(x.D.tj(a, "margin-left")) || 0),
        top: b.top - (parseFloat(x.D.tj(a, "margin-top")) || 0)
    })
};
x.page = x.page || {};
x.page.UD = function () {
    var a = document;
    return ("BackCompat" == a.compatMode ? a.body : a.documentElement).clientWidth
};
x.page.TD = function () {
    var a = document;
    return ("BackCompat" == a.compatMode ? a.body : a.documentElement).clientHeight
};
x.page.kX = function () {
    var a = document;
    return window.pageYOffset || a.documentElement.scrollTop || a.body.scrollTop
};
x.page.jX = function () {
    var a = document;
    return window.pageXOffset || a.documentElement.scrollLeft || a.body.scrollLeft
};
x.im = x.im || {};
x.im.bind = function (a, b) {
    var c = 2 < arguments.length ? [].slice.call(arguments, 2) : p;
    return function () {
        var d = x.lang.ug(a) ? b[a] : a,
            e = c ? c.concat([].slice.call(arguments, 0)) : arguments;
        return d.apply(b || d, e)
    }
};
(function () {
    function a(a) {
        a.x = a[0] || a.x || a.left || 0;
        a.y = a[1] || a.y || a.top || 0;
        return a
    }
    var b = x.Qb.Tl.VY = s();
    b.ra = function (a, b, e) {
        b = x.$(b) || this.ki();
        e = e || {};
        this.wP(b, e.HY, [b, a, e])
    };
    b._positionByCoordinate = function (b, d, e, f) {
        var d = d || [0, 0],
            e = e || {}, g = {}, i = x.page.TD(),
            k = x.page.UD(),
            l = x.page.jX(),
            m = x.page.kX(),
            n = b.offsetWidth,
            u = b.offsetHeight,
            v = b.offsetParent,
            v = !v || v == document.body ? {
                left: 0,
                top: 0
            } : x.D.ha(v);
        e.position = "undefined" !== typeof e.position ? e.position.toLowerCase() : "bottomright";
        d = a(d || [0, 0]);
        e.ya = a(e.ya || [0, 0]);
        d.x += 0 <= e.position.indexOf("right") ? d.width || 0 : 0;
        d.y += 0 <= e.position.indexOf("bottom") ? d.height || 0 : 0;
        g.left = d.x + e.ya.x - v.left;
        g.top = d.y + e.ya.y - v.top;
        switch (e.H2) {
            case "surround":
                g.left += g.left < l ? n + (d.width || 0) : g.left + n > l + k ? -n - (d.width || 0) : 0;
                g.top += g.top < m ? u + (d.height || 0) : g.top + u > m + i ? -u - (d.height || 0) : 0;
                break;
            case "fix":
                g.left = Math.max(0 - parseFloat(x.D.tj(b, "marginLeft")) || 0, Math.min(g.left, x.page.UD() - n - v.left));
                g.top = Math.max(0 - parseFloat(x.D.tj(b, "marginTop")) || 0, Math.min(g.top, x.page.TD() - u - v.top));
                break;
            case "verge":
                var w = -1 < e.position.indexOf("right") ? d.width : 0,
                    y = -1 < e.position.indexOf("bottom") ? d.height : 0,
                    B = -1 < e.position.indexOf("bottom") ? d.width : 0,
                    A = -1 < e.position.indexOf("right") ? d.height : 0;
                g.left -= 0 <= e.position.indexOf("right") ? d.width || 0 : 0;
                g.top -= 0 <= e.position.indexOf("bottom") ? d.height || 0 : 0;
                g.left += g.left + w + n - l > k - v.left ? B - n : w;
                g.top += g.top + y + u - m > i - v.top ? A - u : y
        }
        x.D.ra(b, g);
        !f && (i != x.page.TD() || k != x.page.UD()) && this._positionByCoordinate(b, d, {}, o);
        f || this.dispatchEvent("onpositionupdate")
    };
    b.wP = function (a, b, e) {
        ("undefined" == typeof b || !b) && x.event.K(x.D.AX(a), "resize", x.im.bind.apply(this, ["_positionByCoordinate", this].concat([].slice.call(e))));
        this._positionByCoordinate.apply(this, e)
    }
})();
x.Qb.Gi.extend({
    VY: o,
    nW: o,
    BX: function () {
        var a = this;
        return function () {
            a.rw(o)
        }
    },
    rw: function (a) {
        var b = this.rm(),
            c = this.UB,
            d = this.ki();
        if (this.FA() || !a) c && (b = c), a = x.D.ha(b), b = {
            top: a.top + b.offsetHeight - 1,
            left: a.left,
            width: b.offsetWidth
        }, b = "function" == typeof this.view ? this.view(b) : b, this.ra([b.left, b.top], p, {
            HY: o
        }), x.D.LZ(d, b.width)
    }
});
x.Qb.Gi.Te(function (a) {
    a.R_ = a.BX();
    a.addEventListener("onload", function () {
        a.rw();
        a.nW && (a.oW = setInterval(function () {
            var b = a.ki(),
                c = a.rm();
            0 != b.offsetWidth && (c && c.offsetWidth != b.offsetWidth) && (a.rw(), b.style.display = "block")
        }, 100));
        a.K(window, "resize", a.R_)
    });
    a.addEventListener("onshow", function () {
        a.rw()
    });
    a.addEventListener("ondispose", function () {
        clearInterval(a.oW)
    })
});
x.Qb.Gi.Te(function (a) {
    function b() {
        setTimeout(function () {
            var b = a.rm();
            e = b === p ? "" : b.value
        }, 20)
    }
    var c, d = "",
        e, f, g = q,
        i = q;
    a.addEventListener("onload", function () {
        c = this.rm();
        b();
        a.K(window, "onload", b);
        a.j_ = a.rX();
        a.K(c, "keydown", a.j_);
        c.setAttribute("autocomplete", "off");
        a.gV = setInterval(function () {
            if (!i) {
                x.$(c) == p && a.ei();
                var b = c.value;
                b == d && "" != b && b != e && b != f ? 0 == a.bF && (a.bF = setTimeout(function () {
                    a.dispatchEvent("onneeddata", b)
                }, 100)) : (clearTimeout(a.bF), a.bF = 0, "" == b && "" != d && (f = "", a.U()), d = b, b != f && (a.Qw = b), e != c.value && (e = ""))
            }
        }, 10);
        a.K(c, "beforedeactivate", a.PU)
    });
    a.addEventListener("onitemclick", function () {
        i = q;
        a.Qw = d = a.QD()
    });
    a.addEventListener("onpick", function (a) {
        g && c.blur();
        c.value = f = a.data.item.value;
        g && c.focus()
    });
    a.addEventListener("onmousedownitem", function () {
        i = g = o;
        setTimeout(function () {
            g = i = q
        }, 500)
    });
    a.addEventListener("ondispose", function () {
        clearInterval(a.gV)
    })
});
x.Qb.Gi.extend({
    PU: function () {
        return function () {
            mousedownView && (window.event.cancelBubble = o, window.event.returnValue = q)
        }
    },
    rX: function () {
        var a = this;
        return function (b) {
            var c = q,
                b = b || window.event;
            switch (b.keyCode) {
                case 9:
                case 27:
                    a.U();
                    break;
                case 13:
                    x.event.stop(b);
                    a.confirm(-1 == a.Xc ? a.rm().value : a.pk[a.Xc], "keyboard");
                    break;
                case 38:
                    c = o;
                case 40:
                    x.event.stop(b);
                    b = c;
                    if (a.FA()) {
                        var c = a.pk,
                            d = a.Xc;
                        if (0 != c.length) {
                            if (b) switch (d) {
                                case -1:
                                    d = c.length - 1;
                                    a.zj(c[d]);
                                    a.at(c[d]);
                                    break;
                                case 0:
                                    d = -1;
                                    a.zj(a.Qw);
                                    a.fC();
                                    break;
                                default:
                                    d--, a.zj(c[d]), a.at(c[d])
                            } else switch (d) {
                                case -1:
                                    d = 0;
                                    a.zj(c[d]);
                                    a.at(c[d]);
                                    break;
                                case c.length - 1:
                                    d = -1;
                                    a.zj(a.Qw);
                                    a.fC();
                                    break;
                                default:
                                    d++, a.zj(c[d]), a.at(c[d])
                            }
                            a.Xc = d
                        }
                    } else a.dispatchEvent("onneeddata", a.QD());
                    break;
                default:
                    a.Xc = -1
            }
        }
    },
    Qw: ""
});
ja.e4 = o;
var Lh = q,
    Mh = z.Fc + "res/20/bmap_autocomplete.css",
    Nh = {
        ALL: "0",
        CITY: "1"
    };
x.extend(Gd.prototype, {
    Od: function () {
        this.Qi()
    },
    Qi: function () {
        this.cl = -1;
        this.Da = p;
        this.Wv = [];
        this.NG = 0;
        this.ja = this.bv();
        this.nc.input && (this.aS(), this.yT(), this.vy(this.MH));
        var a = p;
        this.aj && (a = {
            method: "search"
        }, a.arguments = [this.aj]);
        this.DH();
        this.lH(a)
    },
    yT: function () {
        var a = this,
            b = new x.Qb.Gi({
                getData: function (b) {
                    a.FI(b)
                },
                onhide: function () {
                    a.cl = -1;
                    "" === a.mg.QD() && (a.aj = "", a.ja = a.bv())
                },
                onhighlight: function (b) {
                    if (a.Da) {
                        var d = {}, e = {}, e = {
                            index: b.data.index,
                            value: a.Da.Em[b.data.index].value
                        }, d = {
                            index: a.cl,
                            value: 0 <= a.cl ? a.Da.Em[a.cl].value : {}
                        }, f = new N("onhighlight");
                        f.fromitem = f.I1 = d;
                        f.toitem = f.X3 = e;
                        a.dispatchEvent(f);
                        a.cl = b.data.index
                    }
                },
                onbeforepick: function (b) {
                    if (a.Da && "number" === typeof b.data.index) {
                        var d = a.Da.Em[b.data.index].value;
                        b.data.item.content = b.data.item.value = d.province + d.city + d.district + d.street + d.business
                    }
                },
                onconfirm: function (b) {
                    if (a.Da) {
                        Oa(5012);
                        var d = {};
                        "number" === typeof b.data.index && (d = {
                            index: b.data.index,
                            value: a.Da.Em[b.data.index].value
                        }, b = new N("onconfirm"), b.item = b.item = d, a.dispatchEvent(b))
                    }
                }
            });
        b.ta(x.$(this.nc.input), x.$(this.nc.UB));
        this.mg = b
    },
    show: function () {
        this.mg && (this.mg.ki().style.display = "block")
    },
    U: function () {
        this.mg && this.mg.U();
        this.cl = -1
    },
    ei: function () {
        this.mg && this.mg.ei();
        x.lang.Ba.prototype.ei.call(this)
    },
    pF: function (a) {
        this.nc.types = a || [];
        this.DH()
    },
    bn: function (a) {
        this.yd.src = a;
        this.lH()
    },
    search: function (a) {
        this.FI(a)
    },
    vy: function (a) {
        this.mg && this.mg.zj(a)
    },
    FI: function (a) {
        var b = this,
            c = (1E5 * Math.random()).toFixed(0);
        z._rd["_cbk" + c] = function (a) {
            x.$(b.nc.input) !== p && b.yR(a);
            delete z._rd["_cbk" + c]
        };
        var d = z.url.proto + z.url.domain.baidumap + "/su?wd=" + encodeURIComponent(a) + "&callback=BMap._rd._cbk" + c + "&cid=" + b.NG + "&type=" + b.Wv + "&t=" + (new Date).getTime();
        b.aj = a;
        b.cl = -1;
        b.ja = this.bv();
        Oa(5010, {
            tp: b.Wv,
            wd: encodeURIComponent(a)
        });
        Pb(d)
    },
    yR: function (a) {
        a && a.q && (this.aj = a.q);
        this.$T(this.mR(a));
        this.ja = this.bv(this.Da);
        this.nc.$x(this.ja)
    },
    mR: function (a) {
        var b = [],
            c = a.s,
            d = {};
        d.rb = a.q || "";
        d.count = a.s.length || 0;
        d.status = 0 > a.e ? 7 : 0;
        d.Em = [];
        var e = 0,
            f = c.length;
        for (G() && 6 < f && (f = 6) ; e < f; e++) {
            var g = this.JR(c[e], this.Wv);
            d.Em.push(g.value);
            b.push(g.EL)
        }
        this.Da = d;
        return {
            data: b,
            p4: a.q
        }
    },
    $T: function (a) {
        if (this.mg) {
            var b = this.mg;
            b.show(a.word, a.data);
            1 > a.data.length && b.U()
        }
    },
    JR: function (a, b) {
        switch (b.toString()) {
            case "1":
                return this.KR(a);
            default:
                return this.LR(a)
        }
    },
    LR: function (a) {
        for (var a = a.split("$"), b = this.aj, c = RegExp(b, "g"), d = "<b>" + b + "</b>", e = {
            province: "",
            city: a[0],
            district: a[1],
            street: a[2],
            streetNumber: "",
            business: a[3]
        }, f = "", g = 3; 0 <= g; g--)
            if (f = a[g] + f, -1 < f.indexOf(b)) {
                for (var b = g - 1, i = ""; -1 < b;) i = a[b] + i, b--;
                f = f.replace(c, d);
                i && (f += '&nbsp;<span class="tangram-suggestion-grey">' + i + "</span>");
                break
            }
        if (!i)
            for (g = 3; 0 <= g; g--) i += a[g];
        return {
            value: {
                value: e
            },
            EL: f
        }
    },
    KR: function (a) {
        var b = a.split("$"),
            c = this.aj,
            a = {
                province: b[0],
                city: b[1],
                district: "",
                street: "",
                streetNumber: "",
                business: ""
            }, b = (b[0] + b[1]).replace(RegExp(c, "g"), "<b>" + c + "</b>");
        return {
            value: {
                value: a
            },
            EL: b
        }
    },
    DH: function () {
        var a = this.nc.types,
            b = [];
        if (x.ug(a)) b.push(Nh[a.toUpperCase()]);
        else if (x.lang.isArray(a))
            for (var c = 0, d = a.length; c < d; c++) b.push(Nh[a[c].toUpperCase()]);
        this.Wv = 0 < b.length ? b.join(",") : "0"
    },
    lH: function (a) {
        var b = this;
        b.Lg(b.yd, function (c) {
            b.NG = c;
            a && b[a.method].apply(b, a.arguments)
        })
    },
    aS: function () {
        if (!Lh) {
            var a = document,
                b = a.createElement("link");
            b.setAttribute("rel", "stylesheet");
            b.setAttribute("type", "text/css");
            b.setAttribute("href", Mh);
            var c = a.getElementsByTagName("head");
            c.length ? c[0].appendChild(b) : a.documentElement.appendChild(b);
            Lh = o
        }
    },
    bv: function (a) {
        if (!a) return new Oh({
            rb: this.aj,
            total: 0,
            Ek: []
        });
        for (var b = [], c = 0, d = a.Em.length; c < d; c++) b.push(a.Em[c].value);
        return new Oh({
            rb: a.rb,
            total: a.count,
            Ek: b
        })
    }
});
S(lf, {
    show: lf.show,
    hide: lf.U,
    setTypes: lf.pF,
    setLocation: lf.bn,
    search: lf.search,
    setInputValue: lf.vy,
    dispose: lf.ei
});

function Oh(a) {
    this.keyword = a.rb || "";
    this.UA = a.total || 0;
    this.tr = a.Ek && a.Ek.slice(0) || []
}
x.extend(Oh.prototype, {
    vk: function (a) {
        if (this.tr[a]) return this.tr[a]
    },
    Us: t("UA"),
    toString: ca("AutocompleteResult")
});
var Ph = Oh.prototype;
S(Ph, {
    getPoi: Ph.vk,
    getNumPois: Ph.Us
});